//Tela principal que contem todas as outras telas
//e funções que seram dividos em paineis
//0° login 
//1º tela de relatórios e graficos
//2º painel tela de cadastro de grupos
//3º painel tela de cadastro de contas
//4° painel tela de cadastro de cartão
//5° painel mostra a movimentação financeira, e faz lançamento de contas (HOME)
package fmu.pi.view.draw.old;

import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.chart.PieChart;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.PasswordField;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.scene.text.Font;
import javafx.stage.Stage;
import fmu.pi.view.handler.HandlerView;

public class TelaPrincipal extends Application
{
    private String nomeStr; //nome do usuário
    private PasswordField passwordField;
    private Button enterButton; 
    private Button homeButton; 
    private Button groupButton; 
    private Button accountButton; 
    private Button creditCardButton;
    private Button lancamentoButton; 
    private PieChart pieChart;
    private BorderPane firstLayout; 
    private CadastraGrupo painelDeGrupos; 
    private CadastraConta painelDeConta; 
    private CadastraCartao painelDeCartao; 
    private PaneMovimentacao movimentacaoDeConta; 
    HandlerView handler;
    
    @Override
    public void start(Stage stage)
    {
        firstLayout = new BorderPane();
        firstLayout.setTop(new Rectangle(1200, 100, Color.DARKBLUE)); 
        firstLayout.setLeft(new Rectangle(200, 600, Color.DARKBLUE)); 
        
        firstLayout.setTop(titulo()); 
        firstLayout.setLeft(leftBorderPane()); 
        firstLayout.setCenter(new Home()); 
        
        
        //eventos para os botões home, grupo, contas e cartão de credito
        //apenas carrega os paineis no layout principal
        homeButton.setOnAction(new EventHandler<ActionEvent>()
        {
            @Override
            public void handle(ActionEvent event)
            {
                firstLayout.setCenter(new Home()); 
            }
        });
                
        groupButton.setOnAction(new EventHandler<ActionEvent>()
        {
            @Override
            public void handle(ActionEvent event)
            {
                painelDeGrupos = new CadastraGrupo(); 
                firstLayout.setCenter(painelDeGrupos); 
            }
        }); 
        
        accountButton.setOnAction(new EventHandler<ActionEvent>()
        {
            public void handle(ActionEvent event)
            {
                painelDeConta = new CadastraConta(); 
                firstLayout.setCenter(painelDeConta); 
            }    
        }); 
        
        creditCardButton.setOnAction(new EventHandler<ActionEvent>()
        {
            @Override
            public void handle(ActionEvent event)
            {
                painelDeCartao = new CadastraCartao(); 
                firstLayout.setCenter(painelDeCartao); 
            }
        });
        
        lancamentoButton.setOnAction(new EventHandler<ActionEvent>()
        {
            @Override
            public void handle(ActionEvent event)
            {
                movimentacaoDeConta = new PaneMovimentacao(); 
                firstLayout.setCenter(movimentacaoDeConta); 
            }
        });
        
        stage.setScene(new Scene(firstLayout, 900, 650));
        stage.setTitle("$ó No lucro"); 
        stage.setResizable(true);
        stage.centerOnScreen();       
        stage.show(); 
    }
    
    private GridPane leftBorderPane()
    {
        GridPane gridLeft = new GridPane();
        
        //edita o grid
        gridLeft.setHgap(10);
        gridLeft.setVgap(10);
        gridLeft.setStyle("-fx-background-color: DARKBLUE"); 
        for(int i = 0; i < 5; i++)
            gridLeft.add(new Rectangle(200, 100, Color.TRANSPARENT),0, i);
        
        //inicializa e edita os botões
        homeButton = new Button(); 
        homeButton.setText("Home"); 
        homeButton.setFont(Font.font("Ariel Black", 25));
        homeButton.setTextFill(Color.BLUE); 
        homeButton.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE); 
        gridLeft.add(homeButton, 0, 0);
        
        groupButton = new Button(); 
        groupButton.setText("Grupos"); 
        groupButton.setFont(Font.font("Ariel Black", 25)); 
        groupButton.setTextFill(Color.BLUE); 
        groupButton.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
        gridLeft.add(groupButton, 0, 1); 
        
        accountButton = new Button(); 
        accountButton.setText("Contas"); 
        accountButton.setFont(Font.font("Ariel Black", 25));
        accountButton.setTextFill(Color.BLUE); 
        accountButton.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
        gridLeft.add(accountButton, 0, 2);
        
        creditCardButton = new Button(); 
        creditCardButton.setText("Cartão de Credito"); 
        creditCardButton.setFont(Font.font("Ariel Black", 25));
        creditCardButton.setTextFill(Color.BLUE); 
        creditCardButton.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE); 
        gridLeft.add(creditCardButton, 0, 3); 
        
        lancamentoButton = new Button(); 
        lancamentoButton.setText("Lançamentos"); 
        lancamentoButton.setFont(Font.font("Ariel Black", 25)); 
        lancamentoButton.setTextFill(Color.BLUE); 
        lancamentoButton.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
        gridLeft.add(lancamentoButton, 0, 4); 
        
        return gridLeft; 
    }
    
    private HBox titulo()
    {
        HBox box = new HBox(); 
        box.setAlignment(Pos.CENTER);
        box.setMaxSize(1200, 100); 
        box.setStyle("-fx-background-color: DARKBLUE");
        
        Label titulo = new Label();
        titulo.setText("$ó No Lucro"); 
        titulo.setFont(Font.font("Ariel Black", 70)); 
        titulo.setTextFill(Color.LIGHTBLUE); 
        
        box.getChildren().add(titulo); 
        return box; 
    }
    
   
}